package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.WmsWarehouseLocation;
import com.ruoyi.system.domain.vo.SelectVo;
import com.ruoyi.system.mapper.WmsWarehouseLocationMapper;
import com.ruoyi.system.service.IWmsWarehouseLocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 货位信息Service业务层处理
 *
 * @author ruoyi
 * @date 2025-06-17
 */
@Service
public class WmsWarehouseLocationServiceImpl implements IWmsWarehouseLocationService
{
    @Autowired
    private WmsWarehouseLocationMapper wmsWarehouseLocationMapper;

    /**
     * 查询货位信息
     *
     * @param locationId 货位信息主键
     * @return 货位信息
     */
    @Override
    public WmsWarehouseLocation selectWmsWarehouseLocationByLocationId(Long locationId)
    {
        return wmsWarehouseLocationMapper.selectWmsWarehouseLocationByLocationId(locationId);
    }

    /**
     * 查询货位信息列表
     *
     * @param wmsWarehouseLocation 货位信息
     * @return 货位信息
     */
    @Override
    public TableDataInfo<WmsWarehouseLocation> selectWmsWarehouseLocationList(WmsWarehouseLocation wmsWarehouseLocation, PageQuery pageQuery)
    {
        Page<WmsWarehouseLocation> page = wmsWarehouseLocationMapper.selectWmsWarehouseLocationList(pageQuery.build(),wmsWarehouseLocation);
        return TableDataInfo.build(page);
    }

    /**
     * 新增货位信息
     *
     * @param wmsWarehouseLocation 货位信息
     * @return 结果
     */
    @Override
    public int insertWmsWarehouseLocation(WmsWarehouseLocation wmsWarehouseLocation)
    {
        wmsWarehouseLocation.setCreateTime(DateUtils.getNowDate());
        return wmsWarehouseLocationMapper.insertWmsWarehouseLocation(wmsWarehouseLocation);
    }

    /**
     * 修改货位信息
     *
     * @param wmsWarehouseLocation 货位信息
     * @return 结果
     */
    @Override
    public int updateWmsWarehouseLocation(WmsWarehouseLocation wmsWarehouseLocation)
    {
        wmsWarehouseLocation.setUpdateTime(DateUtils.getNowDate());
        return wmsWarehouseLocationMapper.updateWmsWarehouseLocation(wmsWarehouseLocation);
    }

    /**
     * 批量删除货位信息
     *
     * @param locationIds 需要删除的货位信息主键
     * @return 结果
     */
    @Override
    public int deleteWmsWarehouseLocationByLocationIds(Long[] locationIds)
    {
        return wmsWarehouseLocationMapper.deleteWmsWarehouseLocationByLocationIds(locationIds);
    }

    /**
     * 删除货位信息信息
     *
     * @param locationId 货位信息主键
     * @return 结果
     */
    @Override
    public int deleteWmsWarehouseLocationByLocationId(Long locationId)
    {
        return wmsWarehouseLocationMapper.deleteWmsWarehouseLocationByLocationId(locationId);
    }

    @Override
    public List<SelectVo> getWmsWarehouseLocationSelect(){
        return wmsWarehouseLocationMapper.getWmsWarehouseLocationSelect();
    }

    @Override
    public List<SelectVo> getWmsWarehouseLocationSelectByRackId(Long rackId){
        return wmsWarehouseLocationMapper.getWmsWarehouseLocationSelectByRackId(rackId);
    }
}
